package com.jrowny.mediators
{
	import flash.events.Event;
	
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import com.jrowny.proxy.FileProxy;
	
	import com.jrowny.enum.Notes;
	
	public class AppMediator extends Mediator
	{
		public static const NAME:String = "AppMediator";
		public function AppMediator(viewComponent:Object)
		{
			super(NAME, viewComponent);
			spriteHero.addEventListener(SpriteHero.EVENT_EXPORT_CSS,onExportCSS);
			spriteHero.addEventListener(SpriteHero.EVENT_EXPORT_HTML,onExportHTML);
			spriteHero.addEventListener(SpriteHero.EVENT_OPEN_IMAGE,onOpenImage);
			spriteHero.addEventListener(SpriteHero.EVENT_PREVIEW_IN_BROWSER,onPreviewInBrowser);
		}
		//helpful getter, saves us some casting
		public function get spriteHero():SpriteHero{
			return viewComponent as SpriteHero;
		}
		
		private function onPreviewInBrowser(event:Event):void{
			this.sendNotification(Notes.PREVIEW_IN_BROWSER);
		}
		private function onExportCSS(event:Event):void{
			this.sendNotification(Notes.EXPORT_CSS);
		}
		private function onExportHTML(event:Event):void{
			this.sendNotification(Notes.EXPORT_HTML);
		}
		private function onOpenImage(event:Event):void{
			this.sendNotification(Notes.OPEN_FILE);
		}
	}
}